package code.ws_common_scene.texturedata
{
	/**
	 * 动作样式单方向播放数据 
	 * @author qiangchen
	 * 
	 */	
	public class TexturePlayData
	{
		/** 样式 */
		public var style:String;
		/** 动作 */
		public var action:String;
		/** 方向 */
		public var direction:int;
		/** 是否循环播放 */
		public var isLoop:Boolean = false;
		/** 关键帧 */
		public var keyFrame:int;
		/** 方向帧数 */
		public var frameCount:int;
		/** 播放速率 */
		public var frameRate:int;
		/** 当前方向动作播放数据 */
		public var textures:Vector.<Textures> = new Vector.<Textures>;
		/** 当前方向一套动作播放的总时间 */
		public var totalTime:int;
		/** 当前动作播放时间组 */
		public var framesTimeLine:Array = [];
		/** 动作y轴最大高度 */
		public var maxY:int;
		
		
		/**
		 * 构造函数 
		 * 
		 */		
		public function TexturePlayData()
		{
		}
		
		
		
		/**
		 * 初始化数据
		 * 
		 */		
		public function ini():void
		{
			// 初始化播放总时间
			totalTime = 0;
			for( var i:int=0; i<framesTimeLine.length; i++ )
			{
				totalTime += framesTimeLine[i];
			}
			
			// 初始化动作的最大高度
			maxY = textures[j].offy;
			for( var j:int=1; j<textures.length; j++ )
			{
				var t:Textures = textures[j];
				maxY = ( maxY >= t.offy ) ? maxY : t.offy;
				t = null;
			}
		}
		
		
		
		/**
		 * 克隆 
		 * 
		 */		
		public function clone():TexturePlayData
		{
			var texturePlayData:TexturePlayData = new TexturePlayData();
			texturePlayData.action = action;
			texturePlayData.style = style;
			texturePlayData.direction = direction;
			texturePlayData.frameCount = frameCount;
			texturePlayData.frameRate = frameRate;
			texturePlayData.isLoop = isLoop;
			texturePlayData.keyFrame = keyFrame;
			texturePlayData.totalTime = totalTime;
			texturePlayData.textures = textures.slice();
			texturePlayData.framesTimeLine = framesTimeLine;
			texturePlayData.ini();
			return texturePlayData;
		}
		
		/**
		 * 释放 
		 * 
		 */		
		public function die():void
		{
			style = null;
			action = null;
			direction = -1;
			keyFrame = -1;
			frameCount = -1;
			frameRate = -1;
			textures.length = 0;
			textures = null;
			totalTime = -1;
			framesTimeLine.length = 0;
			framesTimeLine = null;
			maxY = -1;
		}
	}
}